package com.keba.lamp.ai.controller;

import com.keba.basic.base.R;
import com.keba.basic.interfaces.echo.EchoService;
import com.keba.lamp.ai.entity.AiModel;
import com.keba.lamp.ai.service.AiModelService;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import com.keba.basic.base.controller.SuperController;
import com.keba.lamp.ai.service.AiModelVersionService;
import com.keba.lamp.ai.entity.AiModelVersion;
import com.keba.lamp.ai.vo.save.AiModelVersionSaveVO;
import com.keba.lamp.ai.vo.update.AiModelVersionUpdateVO;
import com.keba.lamp.ai.vo.result.AiModelVersionResultVO;
import com.keba.lamp.ai.vo.query.AiModelVersionPageQuery;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 前端控制器
 * 模型版本
 * </p>
 *
 * @author twg
 * @date 2025-03-22 13:59:56
 * @create [2025-03-22 13:59:56] [twg] [代码生成器生成]
 */
@Slf4j
@RequiredArgsConstructor
@Validated
@RestController
@RequestMapping("/aiModelVersion")
@Tag(name = "模型版本")
public class AiModelVersionController extends SuperController<AiModelVersionService, Long, AiModelVersion
        , AiModelVersionSaveVO, AiModelVersionUpdateVO, AiModelVersionPageQuery, AiModelVersionResultVO> {
    private final EchoService echoService;

    private final AiModelService aiModelService;

    @Override
    public EchoService getEchoService() {
        return echoService;
    }


    @Override
    public R<List<AiModelVersionResultVO>> query(AiModelVersionPageQuery data) {
        R<List<AiModelVersionResultVO>> list = super.query(data);
        list.getData().forEach(item -> {
            AiModel aiModel = aiModelService.getById(item.getModelId());
            if (null != aiModel) {
                item.setBrandName(aiModel.getBrandName()).setModelName(aiModel.getModelName());
            }
        });
        return list;
    }
}


